﻿<!doctype html>
<html>
	<head>
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0">
		<title>商家信息</title>
		<link href="css/style.css" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
		<script type="text/javascript" src="js/jquery.pager.js"></script>
		<script type="text/javascript" src="js/header&footer.js"></script>
		<script type="text/javascript" src="js/common.js"></script>
		<script type="text/javascript" src="js/utils.js"></script>
		<script type="text/javascript" src="js/gbRst.js"></script>
		<script type="text/javascript" src="js/openId1.js"></script>
	<script type="text/javascript" src="js/qmsk-1.2.js"></script>
		<script type="text/javascript">
		var thisShopId
			$(function() {
			 thisShopId =getIdByName("thisShopId");
				loadShopDetail(thisShopId);
			});

			/**
			 * 从服务器请求 shopId 对应的商店的详细信息
			 */
			function loadShopDetail(shopId) {
				$.get('../shop/find/shopId/' + shopId, function(message) {
					if (IsEmpty(message)) {
						alert('没有查询到数据！');
						return;
					}
					if (message.state === 0) {
						printDataToPage(message);
					} else {
						alert(message.msg);
					}
				}, 'json');
			}

			//获取店铺优惠券
			function insertMbCoupbill() {
				window.location.href="coupons.html?openId="+_openId+"&shopId="+_shopId+"&thisShopId="+thisShopId;
			}

			/**
			 * 将数据显示到页面上
			 */
			function printDataToPage(message) {
				/* shopName,tel,email,fax,website,zipCode,address,imageURL,shopImgURL1,shopImgURL2,shopImgURL3,shopImgURL4,major,memo */
				var shopName = getHeadIndexValue(0, message, 'name');
				for ( var i = 0; i < 7; i++) {
					var imageUrl = getHeadIndexValue(0, message, 'imgURL'+i);
					if(IsNotEmpty(imageUrl)){
						var url= "<img src=\""+imageUrl+"\" data-src=\""+imageUrl+"\" data-gid=\"g0\" onload=\"preViewImg(this, event);\">"
					$("#imageS").append(url)
					}
				}
				
				
				
				$("#imageUrl").attr("src",getHeadIndexValue(0, message, 'imgURL1'));
				var address = getHeadIndexValue(0, message, 'addr');
				$("#address").html('商家地址：' + address);
				var tel = getHeadIndexValue(0, message, 'tel');
				$("#tel").html(tel);
				$("#tel").attr("href", "tel:" + tel);
				var longitude = getHeadIndexValue(0, message, 'lng');
				//百度地图备用，经度
				var latitude = getHeadIndexValue(0, message, 'lat');
				//百度地图备用，纬度
				var idxUrl = getHeadIndexValue(0, message, 'idxUrl');
				$("#shopName").html(shopName)
				var mapHref="http://api.map.baidu.com/marker?zoom=11&location="+latitude+","+longitude+"&title="+encodeURIComponent(shopName)+"&content="+encodeURIComponent(address)+"&output=html&src=qmsk"
				$("#address").attr("href",mapHref)
				getHtml(idxUrl)
			}
			
			
			function getHtml(url){
				$.ajax({
					url:'../htmlUtils/find/getHtml',
					data:{'htmlUrl':url},
					type:'post',
					success:function(data){
					var dt = JSON.parse(data);
						if(dt.state==0){
							var html = getHtmlString(getHeadIndexValue(0, dt, "htmlStr"))
							$("#DIY").append(html)
						}
					}
				})
			}
		</script>
		
	</head>
<body>
    <div class="wrapper">
<div class="placeTit"><a href="javascript:history.go(-1)" class="back"></a>商家信息</div>
<div class="container" id="content">
<div class="actor">
  <dl>
    <dt>
        <figure  class="comeGift">
            <div id="imageS">
            <!-- <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            <img src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-src="http://img.weimob.com/67/05/d7/sns/20140313205136_49500.jpg" data-gid="g0" onload="preViewImg(this, event);">
            --> </div>
        </figure>
    <!--<img src="http://localhost:8080/transmoo/activity/27/indexImage.png" id="imageUrl">--></dt>
    <dd><strong id="shopName"></strong> 
      <!--           <p>活动时间：<span id="beginTime">2014-01-15</span>至<span id="endTime">2014-02-18</span></p>
--> </dd>
  </dl>
  <div style="margin:10px auto 0;" class="bottomBtn">
    <input type="button" class="btn" onclick="insertMbCoupbill()"  value="点击获取优惠券">
  </div>
</div>
<div id="DIY"></div>
<h3 class="title">联系我们</h3>
<div class="friendlink">
  <p class="txt"> 商家服务热线：<a id="tel"></a> </p>
  <a class="txt" id="address"></a>
</div>
</div>
</div>
</body>
</html>
